import React, { Component } from 'react';
import { TabBar } from 'antd-mobile';
import { withRouter } from 'react-router-dom'
class Tarbar extends Component{
    render(){
        const navList = this.props.navList.filter(v=>!v.hide)
        const path = this.props.location.pathname
        return (
           <div className='tarbar'>
               <TabBar>
                {navList.map(item=>
                    (<TabBar.Item
                        title={item.title}
                        key={item.title}
                        icon={{uri:require(`./img/${item.icon}.png`)}}
                        selectedIcon={{uri:require(`./img/${item.icon}-active.png`)}}
                        selected={path===item.path}
                        onPress={() => {
                          this.props.history.push(item.path)
                        }}
                      >
                      </TabBar.Item>)
                )}
                </TabBar>
           </div>
        )
    }
}

Tarbar = withRouter(Tarbar)
export default Tarbar
